<?php

use App\Core\Traits\Database\SchemaCommentTrait;
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

class CreateUserTable extends Migration
{
    use SchemaCommentTrait;

    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('users', function (Blueprint $table) {
            $table->bigIncrements('id')->comment('用户注册自然ID');
            $table->string('username', 100)->comment('用户名')->unique();
            $table->string('nickname', 100)->comment('用户昵称')->index();
            $table->smallInteger('gender')->default(0)->comment('用户性别,enums:[0:未知,1:男,2:女]');
            $table->string('mobile', 20)->nullable(true)->comment('用户手机号')->index();
            $table->string('email', 100)->nullable(true)->comment('用户注册邮箱')->index();
            $table->bigInteger('avatar_id')->nullable(false)->default(0)->comment('用户头像id');
            $table->string('uuid', 128)->unique()->comment('用户平台唯一身份ID');
            $table->dateTime('created_at')->nullable(false)->comment('创建时间');
            $table->dateTime('updated_at')->nullable(false)->comment('更新时间');
            $table->dateTime('deleted_at')->nullable(true)->comment('用户删除时间');
        });
        $this->comment('users', "平台用户信息表(基础)");
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('users');
    }
}
